package com.qf.serviceimpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsGoodsSpecificationMapper;
import com.qf.pojo.DtsGoodsSpecification;
import com.qf.service.DtsGoodsSpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author Ypl
 * @version V1.0
 * @Project September-mavens
 * @Package com.qf.serviceimpl
 * @Description:
 * @Date 2022/10/17 22:23
 */
@Service
public class DtsGoodsSpecificationServiceImpl implements DtsGoodsSpecificationService {
    @Autowired
    DtsGoodsSpecificationMapper dtsGoodsSpecificationMapper;


    @Override
    public void insert(DtsGoodsSpecification specification) {
        specification.setDeleted(false);
        specification.setAddTime(new Date());
        specification.setUpdateTime(new Date());

        dtsGoodsSpecificationMapper.insert(specification);
    }

    @Override
    public List<DtsGoodsSpecification> findByGoodsId(Integer goodsId) {

        LambdaQueryWrapper<DtsGoodsSpecification> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsSpecification::getGoodsId,goodsId);
        wrapper.eq(DtsGoodsSpecification::getDeleted,false);

        return dtsGoodsSpecificationMapper.selectList(wrapper);
    }

    @Override
    public void delete(Integer id) {
        dtsGoodsSpecificationMapper.deleteById(id);
    }
}
